package com.ztgf.logistics.service.deppon;

import com.ztgf.common.enums.CodeEnum;
import com.ztgf.dubbo.exception.ServiceException;
import org.apache.dubbo.config.annotation.DubboService;
import javax.annotation.Resource;
import com.ztgf.logistics.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.logistics.mapper.deppon.LogisticsUserMoneyLogMapper;
import com.ztgf.logistics.models.service.deppon.ILogisticsUserMoneyLogService;
import com.ztgf.logistics.models.dto.deppon.LogisticsUserMoneyLogDTO;

import java.math.BigDecimal;

/**
 * 物流信息金额流水记录表控制器
 *
 * @author mxli
 * @Date 2021-09-13 22:17:24
 */
@DubboService
public class LogisticsUserMoneyLogServiceImpl extends ServiceImpl<LogisticsUserMoneyLogMapper, LogisticsUserMoneyLogDTO> implements ILogisticsUserMoneyLogService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public void insert(Long businessId, Long shopId, Integer type, BigDecimal money, BigDecimal mguaranteeMoneyQuota, BigDecimal mguaranteeMoney, BigDecimal logisticsMoneyQuota, BigDecimal logisticsMoneyUsed, BigDecimal logisticsMoneyUnused, BigDecimal logisticsMoneyUsedScale, Long createUserId, String createUserName, CodeEnum codeEnum) {
        LogisticsUserMoneyLogDTO dto = new LogisticsUserMoneyLogDTO();

        Long id = ymlConfig.getPkId();
        dto.setId(id);
        dto.setCreateUserId(createUserId);
        dto.setCreateUserName(createUserName);
        dto.setShopId(shopId);
        dto.setBusinessId(businessId);
        dto.setType(type);
        dto.setMoney(money);
        dto.setMguaranteeMoneyQuota(mguaranteeMoneyQuota);
        dto.setMguaranteeMoney(mguaranteeMoney);
        dto.setLogisticsMoneyQuota(logisticsMoneyQuota);
        dto.setLogisticsMoneyUnused(logisticsMoneyUnused);
        dto.setLogisticsMoneyUsed(logisticsMoneyUsed);
        dto.setLogisticsMoneyUsedScale(logisticsMoneyUsedScale);
        if(!this.insert(dto)){
            throw new ServiceException(codeEnum);
        }
    }
}
